<div class="modal-dialog " id="metaGenObj_A_Dialog">
  <div class="modal-content">
    <div class="modal-header modal-header-condensed">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">×</span></button>
      <h4 class="modal-title"><i class="fa fa-plus"></i>新增元对象</h4>
    </div>
    <div class="modal-body">
      <form class="form-horizontal" id="add_form_metaGenObj" role="form"  >
        <div class="form-group">
          <span class=" col-xs-3 control-label" >名称</span>
          <div class=" col-xs-9">
            <input type="text" class="form-control" placeholder="对象的英文类名" name="objName" id="objName" >
          </div>
        </div>
        <div class="form-group">
          <span class=" col-xs-3 control-label" >备注</span>
          <div class=" col-xs-9">
            <input type="text" class="form-control" placeholder="对象的中文类名" name="objComment" id="objComment">
          </div>
          
        </div>
        <div class="form-group">
          
          <span class=" col-xs-3 control-label" >包名</span>
          <div class=" col-xs-9">
            <input type="text" class="form-control" placeholder="元对象的包名" name="objPackageName" id="objPackageName">
          </div>
        </div>
        <div class="form-group">
          <span class=" col-xs-3 control-label" >类的全名</span>
          <div class=" col-xs-9">
            <input type="text" class="form-control" placeholder="元对象的完整类名" name="objTypeName" id="objTypeName">
          </div>
        </div>
      </form>
    </div>
    <div class="modal-footer modal-footer-condensed ">
      <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      <button type="button" class="btn btn-primary" id="metaGenObj_A_Btn">确认</button>
    </div>
  </div>
</div>
<script type="text/javascript">
  require([ "jquery","framework","validate"],function($) {
    var $container = $("#metaGenObj_A_Dialog");
    var $parentContainer  = $container.parent();
    var reftableid = $parentContainer.data('reftableid');
    ${generateValidateJS("#add_form_metaGenObj","frameworkOptions.showValidateMessages","com.maker.generator.entity.MetaGenObj","")};

    function validateAddFrom(){ 
        var addFromData = new Object();
        
        addFromData.objName =         $container.find('#objName').val();
        addFromData.objComment =      $container.find('#objComment').val();
        addFromData.objPackageName =  $container.find('#objPackageName').val();
        addFromData.objTypeName =     $container.find('#objTypeName').val();
        
        if(!$container.find("#add_form_metaGenObj").valid()) {
            addFromData.validated = false;
        }else{
            addFromData.validated = true;
        }
        
        return addFromData;
    };
  
    //$.Framwwork.showValidateMessage("哈哈");
    $container.find('#metaGenObj_A_Btn').on('click',function(e){
        var postData = validateAddFrom();
        if(postData.validated){
            delete postData.validated;
            $.ajax({
                type: "POST",
                url: "${contextPath}/metaGenObj/add",
                dataType:"json",
                contentType:"application/json",
                async: false,
                data:JSON.stringify(postData),
                success: function(data){
                  if("success" == data.status){
                    $('body').tipCenter('clear');
                    $('body').tipCenter('success',data.message);
                    $('#'+reftableid).bootstrapTable('refresh'); 
                    $parentContainer.modal('hide');  
                  }else if("failure" == data.status){

                    if(data.validateMessages){
                      $('body').tipCenter('warning',data.validateMessages);
                    }else{
                      $('body').tipCenter('error',data.message);
                    }
                      
                  }
                    
                }
            });
        }
    });

    
    
    
  });
</script>
  